<?php
/**
 * Author: Administrator
 * Date: 2022/7/16 1:48
 */

namespace DesignPatterns\Creation\Pool;


class Worker
{

    public function __construct()
    {
        // worker 的初始化比较昂贵，比如连接远程服务，数据库连接，开辟子进程等等
        // 因此需要回收再利用
        echo "Worker created".PHP_EOL;
    }

    public function run($image, $callback): void
    {
        echo var_export($image, true).PHP_EOL;
        call_user_func($callback, $this);
    }

}